/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.sys.util.common;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.govProcure.bean.BuildAssetBean;
import com.yunhoo.sys.db.util.IbatisTemplate;
import com.yunhoo.sys.login.LoginBean;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public class SysConfigMap {

    public static Map<String, String> getSysConfigMap(String config_type) {
        if (config_type == null || config_type.isEmpty()) {
            return null;
        }
        return initMap(config_type);
    }

    private static Map<String, String> initMap(String config_type) {
        SqlMapClient client = IbatisTemplate.getSqlMapClient();
        Map<String, String> map = null;
        try {
            client.startTransaction();
            
            Map paramMap = new HashMap();
            paramMap.put("config_type",config_type);
            map = client.queryForMap("sysConfig.queryMapConfig", paramMap, "key", "value");
            
            client.commitTransaction();
        } catch (SQLException ex) {
            try {
                client.endTransaction();
            } catch (SQLException ex1) {
                Logger.getLogger(LoginBean.class.getName()).log(Level.SEVERE, null, ex1);
            }
            Logger.getLogger(BuildAssetBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        return map;
    }
}
